home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
batchut
/
compdate.zip
/
COMPDATE.DOC
next >
Wrap
Text File
|
1993-05-01
|
7KB
|
149 lines
COMPDATE Compare dates/times/sizes for two files; set errorlevel if different.
Copyright (c) 1993 Creativity in Action. All rights reserved.
SUMMARY
=======
COMPDATE compares the dates, times and sizes of two files. If all three
match, the errorlevel flag is set to zero, otherwise it's set to some other
number. This flag can be checked in a batch file, detecting when a file has
changed. Network administrators can use it to insure that client support
files match master files on the server. By testing the errorlevel, the master
files can be copied only if there's been a change. If nothing has changed, no
copies are made and thus the system runs much faster.
SYNTAX
======
COMPDATE [/Help] [/Quiet] [d:][path]file1[.ext] [d:][path]file2[.ext]
or
COMPDATE [/Help] [/Quiet] [/All] @[d:][path]listfile[.ext]
Where:
[d:][path]file1[.ext] and
[d:][path]file2[.ext] specify the files to be compared, including
optional drive, path, and extension
parameters, and
[d:][path]listfile[.ext] specifies a list file containing a list of
all the files to be compared.
Three switches are available:
/H Help. Displays basic help information.
/Q Quiet mode. Do not display messages. Useful in a batch file.
/A AllFiles mode. If using a list file, check every pair in the list
for differences. Normally COMPDATE will bail out
after the first difference is detected.
By the way, we've tried to make this program as robust as possible. If you
enter hyphens or backslashes instead of a forward slash, the switches will
still work. We've also allowed for the help switch to be coded with /H (as is
common in DR-DOS), /? (as used in MS-DOS) and ? (as used by Norton Utilities).
RETURN VALUES
=============
COMPDATE returns the following errorlevel codes
errorlevel meaning
---------- -------
0 date/time/size identical
1 first file not found
2 second file not found
3 both files not found
4 dates are different
5 times are different
9 dates/times are both different
10 file sizes are different
14 file sizes and dates are different
15 file sizes and times are different
19 file sizes, dates, and times are all different
126 unable to open or read list file
127 help was requested; comparison not performed
USING A LIST FILE
=================
Sometimes you wish to compare several file pairs at a time. If any one pair
has a different size or date or time stamp, you want to perform some general
operation. Rather than write a batch file that runs COMPDATE several times,
you can create a separate ASCII list file that contains all the pair names you
wish to compare. Since this must be an ASCII file, be sure to use an
appropriate ASCII editor. DR-DOS's EDITOR.EXE, MS-DOS's EDIT.COM or
EDLIN.COM, or XyQuest's XyWrite word processor are all useful.
This list file needs to contain two filenames on each line of text. You can
identify comment lines with an asterisk (*), ampersand (&) or semicolon (;) at
the beginning of the line. If COMPDATE encounters a comment line it will go
on to the next line without performing the date/time comparison.
Here is a sample list file called MENU.LST:
; this file compares network menu files with menu files on the user's drive
; if the files have different date or time stamps, a separate batch file will
; copy all these files from the n: drive to the u: drive
n:\menusys\menusys.mnu u:\menusys\menusys.mnu
n:\menusys\menusys.mbt u:\menusys\menusys.mbt
n:\menusys\comm.mnu u:\menusys\comm.mnu
n:\menusys\comm.mbt u:\menusys\comm.mbt
n:\menusys\demos.mnu u:\menusys\demos.mnu
n:\menusys\demos.mbt u:\menusys\demos.mbt
n:\menusys\mgmt.mnu u:\menusys\mgmt.mnu
n:\menusys\mgmt.mbt u:\menusys\mgmt.mbt
EXAMPLE 1 - CHECKING A SINGLE FILE PAIR
=======================================
As a network administrator, you have added a utility called MY_UTIL.EXE to
everyone's local hard disk C: in the \UTILITY directory. A while later you
improve the program. You want to be sure that everyone has the latest
version; if they don't, you want to copy it to their hard disks when they log
on. In a batch file that's run from a login script, you include the following
lines:
COMPDATE n:\global\utility\my_util.exe c:\utility\my_util.exe /q
if not errorlevel 1 goto util_current
copy n:\global\utility\my_util.exe c:\utility\my_util.exe > nul
:util_current
EXAMPLE 2 - CHECKING A LIST OF FILES
====================================
You have defined a nested menu screen system for everyone in your group.
Because of the way the software works, each user must have a personal copy
installed on U:, their user drive. Unfortunately, it's possible for the users
to (inadvertently or not) modify their copy of the menu files. Compounding
the problem, numerous files are needed in order to run. You want to insure
that every user is running the same menu as defined by the master menu on
network drive N:. If any one file is missing or different, you want to recopy
the whole set to the user's U: drive.
First you create the list file MENU.LST as illustrated earlier. Then, in a
batch file that's run from a login script, you include the following lines:
COMPDATE @n:\menusys\menu.lst /q
if not errorlevel 1 goto menu_current
copy n:\menusys\menusys.* u:\menusys > nul
copy n:\menusys\comm.* u:\menusys > nul
copy n:\menusys\demos.* u:\menusys > nul
copy n:\menusys\mgmt.* u:\menusys > nul
:menu_current
HISTORY
=======
Version 1.00 Initial release
Version 1.10 Added test for file size, changed errorlevel values
SHAREWARE
=========
This program was written as shareware; your comments are welcome. However, we
reserve the copyright for the program. If you find COMPDATE useful, send
ten bucks to
Creativity in Action, P. O. Box 6026, Fullerton, CA 92634-6026.
You're welcome--nay, encouraged--to distribute the program as long as you
don't charge anything for it and don't change it in any way. Be sure to
include the documentation file when you distribute it. You corporate guys--
send a few extra bucks if you're going to use it all over the place.
Thanks for your support ....